import { http } from '@/utils'
// 发表文章与草稿
export const reqPublishUpload = (data, isDraft, isEait) => {
  return async () => {
    if (isEait) {
      // 编辑
      await http.put(`/mp/articles/${data.id}`, data)
    } else {
      // 发布
      await http.post(`/mp/articles?draft=${isDraft}`, data)
    }
  }
}

/**
 *获取文章详情
 */
export const getArticleById = (id) => {
  return async () => {
    const res = await http.get(`/mp/articles/${id}`)

    return res.data.data
  }
}
